<?php

use Faker\Factory as Faker;
use App\Models\GoodsSlideshow;
use App\Repositories\GoodsSlideshowRepository;

trait MakeGoodsSlideshowTrait
{
    /**
     * Create fake instance of GoodsSlideshow and save it in database
     *
     * @param array $goodsSlideshowFields
     * @return GoodsSlideshow
     */
    public function makeGoodsSlideshow($goodsSlideshowFields = [])
    {
        /** @var GoodsSlideshowRepository $goodsSlideshowRepo */
        $goodsSlideshowRepo = App::make(GoodsSlideshowRepository::class);
        $theme = $this->fakeGoodsSlideshowData($goodsSlideshowFields);
        return $goodsSlideshowRepo->create($theme);
    }

    /**
     * Get fake instance of GoodsSlideshow
     *
     * @param array $goodsSlideshowFields
     * @return GoodsSlideshow
     */
    public function fakeGoodsSlideshow($goodsSlideshowFields = [])
    {
        return new GoodsSlideshow($this->fakeGoodsSlideshowData($goodsSlideshowFields));
    }

    /**
     * Get fake data of GoodsSlideshow
     *
     * @param array $postFields
     * @return array
     */
    public function fakeGoodsSlideshowData($goodsSlideshowFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'goods_id' => $fake->randomDigitNotNull,
            'url' => $fake->word,
            'created_at' => $fake->word,
            'updated_at' => $fake->word
        ], $goodsSlideshowFields);
    }
}
